<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>联箱会员登录</title>
<link rel="icon" type="image/x-icon" href="${basePath }static/img/HomePageImg/L.jpg" />
<link rel="stylesheet" type="text/css" href="${basePath }static/bootstrap-3.3.7/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${basePath }static/css/HomePageCss/login.css"  />
</head>

<body>
	<div>
		<div class="be-content pren">
			<div class="ioc_text">
				<div class="联想会员登录"></div>
			</div>

			<div>
				<form id="form1">
					<div class="br-content">

						<div class="bootint">
							<span class="input-group-text "><i class="glyphicon glyphicon-user"></i></span> 
							<input type="text" class="form-control form-control1 " id="usertel" name="usertel"
								placeholder="请输入用户名/手机号">
						</div>

						<div class="bootint">
							<span class="input-group-text"><i
								class="glyphicon glyphicon-lock"></i></span> <input type="password"
								class="form-control form-control1" id="userpsw" name="userpsw"
								placeholder="请输入用户密码">
						</div>

						<div class="br-text">
							<p>
								<a href="${basePath }jump?pg=userlogin_2">点此使用验证码登录</a>
							</p>
							<p>
								<span>还没有注册？</span> <a href="${basePath }jump?pg=userMessage/registe" target="_parent">点此注册新用户</a>
							</p>
						</div>
						<div style="padding-top: 25px">
 							<input type="button" class="btn btn-danger btn-lg btn-block" 
							value="登录" onclick="checkMe()"> 
						</div>
						<div class="be-con">
							<span>正在使用账号密码登录</span>
						</div>
					</div>
				</form>
			</div>

		</div>
	</div>

</body>

<script type="text/javascript" src="${basePath }static/js/HomePageJs/iquery-1.12.4/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="${basePath }static/js/HomePageJs/layer-v3.1.1/layer/layer.js"></script>
<script type="text/javascript">
	// 验证form表单是否合法
	function checkMe() {
		// 错误提示信息
		var strMsg = "";
		// 用户名验证
		var usertel = document.getElementById("usertel").value;
		if (usertel == null || usertel == "") {
			// 增加提示信息
			strMsg += "请输入用户名!\n";
		}

		// 密码验证
		var userpsw = document.getElementById("userpsw").value;
		if (userpsw == null || userpsw == "") {
			// 增加提示信息
			strMsg += "请输入密码!\n";
		}

		// 判定整个表单是否可以进行提交
		if (strMsg == "") {
			// 验证通过
			ajaxLogin();
			return true;
		} else {
			// 验证不通过
			//alert(strMsg);
			parent.layer.msg(strMsg, {icon:7});
			return false;
		}
	}
	
//	手动提交form表单
 	function doSubmit() {
 		document.getElementById("form1").submit();
	}

	//使用ajax实现登录
	function ajaxLogin() {
		$.ajax({
			type : "POST", // 请求类型
			url : "LoginAction", // 请求的url
			data : $("#form1").serializeArray(),// 发送的数据 使用serialize方法替代手动拼写数据串
			//dataType : "json",
			//contentType:"application/x-www-form-urlencoded",
			success : function(data, textStatus, jqXHR) { // 执行成功之后的回调函数
				// 回调函数的dom操作
				console.info(data);
				if (data==1) {
					parent.layer.msg('登陆成功！',{icon:1});
					//alert('登录成功！');
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
					//window.location.replace("homepage.jsp")
					//window.location.href='homepage.jsp';
					window.open('index.jsp','_parent');
					//window.open('homepage.jsp');
					//window.location.reload();
					location.reload();
				} else {
					parent.layer.msg('登录失败，请重新输入！',{icon:2});
					//alert('登录失败，请重新输入！');
					window.location.href='${basePath }jump?pg=userlogin_1';
				}
			},
			error : function(xhr, msg, err) {
				var json= JSON.stringify(msg);
				parent.layer.alert('mmp'+json);
				//alert("mmp" + data);
			}
		});
	}
</script>

</html>